package jp.co.sopia;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;

public class MainTabBar extends TabActivity {
	private TabHost tabHost;
	private Button addNote;
	private Button cancel;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tab);
        
        tabHost = (TabHost) findViewById(android.R.id.tabhost);
        /** TabSpec used to create a new tab.
        * By using TabSpec only we can able to setContent to the tab.
        * By using TabSpec setIndicator() we can set name to tab. */

        /** tid1 is firstTabSpec Id. Its used to access outside. */
        TabSpec firstTabSpec = tabHost.newTabSpec("Basic");
        TabSpec secondTabSpec = tabHost.newTabSpec("Date");

        /** TabSpec setIndicator() is used to set name for the tab. */
        /** TabSpec setContent() is used to set content for a particular tab. */
        final Intent basicTab = new Intent(this,BasicTab.class);
         Intent dateTab = new Intent(this,DateTab.class);
        
        if(this.getIntent().getExtras() != null) {
	        basicTab.putExtras(this.getIntent().getExtras());
	        dateTab.putExtras(this.getIntent().getExtras());
        }
        
        firstTabSpec.setIndicator("Basic").setContent(basicTab);
        secondTabSpec.setIndicator("Date").setContent(dateTab);
        
        /** Add tabSpec to the TabHost to display. */
        tabHost.addTab(firstTabSpec);
        tabHost.addTab(secondTabSpec);
        tabHost.setOnTabChangedListener(new OnTabChangeListener() {
			
			public void onTabChanged(String tabId) {
				// TODO Auto-generated method stub
				
			}
		});
        
        addNote = (Button) findViewById(R.id.ok);
        addNote.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
//				tabHost.getTabWidget()
				basicTab.resolveActivity(getPackageManager());
			}
		});
        cancel = (Button) findViewById(R.id.cancel);
        
        
    }
}